
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-23
 * @see :
 */

public abstract class Bool {

    public final static int    $   = GroupRoot.$BOOL$;
    public final static String _   = "BOOL$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
                                                .lang(Language.$EN_US, "boolean")
                                                .lang(Language.$ZH_CN, "布尔值")
                                                .done();
    
    public final static int    $TRUE  = $ + 1;
    public final static String _TRUE  = "BOOL$TRUE";
    @SystemData
    public final static Code   TRUE   = CodeBuilder.code($, $TRUE, _TRUE)
                                                   .lang(Language.$EN_US, "true")
                                                   .lang(Language.$ZH_CN, "真")
                                                   .done();
    public final static int    $FALSE  = $ + 2;
    public final static String _FALSE  = "BOOL$FALSE";
    @SystemData
    public final static Code   FALSE   = CodeBuilder.code($, $FALSE, _FALSE)
                                                   .lang(Language.$EN_US, "false")
                                                   .lang(Language.$ZH_CN, "假")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($TRUE == id) return true;
        if($FALSE == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($TRUE == id) return TRUE;
        if($FALSE == id) return FALSE;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_TRUE.equals(key)) return TRUE;
        if(_FALSE.equals(key)) return FALSE;
        return null;
    }
}
